<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/stylesite.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/styleleft.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/mystyle.css" medial="all" />
	<script src="../js/jquery-1.8.2.min.js" ></script>
	<script src="../js/image.js" type="text/javascript"></script>
        <script src="../js/jsearch.js" type="text/javascript"></script>  
	<script type="text/javascript">
	$(function(){
             $("#showhidecomment").hide();
		$(".button a").click(function(){
		$(this).parent().addClass('current');
		$(this).siblings().removeClass('current');
		});
               
		});
		
	</script>
         <script type="text/javascript">
        var xmlHttp;
		function comment()
		{
                    var Article_ID=document.getElementById("Article_ID").value;
                    var hoten=document.getElementById("name").value;
                    var email=document.getElementById("email").value;
                    var content=document.getElementById("content").value;
                    if(hoten=="Họ tên"|| email=="Email"|| content=="")  
                        document.getElementById("test").innerHTML="<font color='red'>Kiểm tra dữ liệu nhập vào nhé!</font>";
                  else
                      {
                          var xmlHttp;
                if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                                 var CountComment=document.getElementById("CountComment").value;
                     var incount=parseInt(CountComment, 0);
                                document.getElementById("countcomment").value="";
                                document.getElementById("name").value="";
                                document.getElementById("email").value="";
                                document.getElementById("content").value="";
                                document.getElementById("countcomment").innerHTML=incount+1;
                     		document.getElementById("test").innerHTML=xmlHttp.responseText;                
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                         document.getElementById("content").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Comment_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?name="+hoten+"&email="+email+"&content="+content+"&Article_ID="+Article_ID;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null); 
                      }
//                     
		}
   
		
	</script>
        
<title>BÀI VIẾT - TIN TỨC</title>
</head>

<body class="pagebody">
	<div id="wrapwebsite" >
				<?php 
			include('../element/header.php');?>
			<div class="imagestop"></div>
			<div class="wrapmaincontent">
		<?php
		include('../element/leftside.php');
		?>
		<div class="center-leftmargin">
                    <div class="modulecontent">
                        <?php 
                             include 'Article_model.php';
                             $ID_Article=$_GET['ID_Article'];
                             $arr_article=  getAllow();
                             $count=  CommentCount($ID_Article);
                             $article= getArticle($ID_Article);     
                          foreach ($article as $a) {  
                    ?>
                        <input type="hidden" id="Article_ID" name="Article_ID" value="<?php echo $ID_Article; ?>">
                        <input type="hidden" id="CountComment" name="CountComment" value="<?php echo $count; ?>">
                        <table>
                            <tr>
                                <td class="title-article"><?php echo $a[0]; ?></td>
                            </tr>
                              <tr>
                                 <td class="author-article">Tác giả:  <?php echo $a[2]; ?></td>                            
                            </tr>
                            <tr>
                                <td> <?php echo $a[1]; ?></td>                            
                            </tr>                         
                        </table>  
                        <div class="meniu"></div>
                <a href='javascript:history.go(-1)'>Quay lai</a>
                <?php }
                    
                ?>
               
                <table width="700px" class="comment">                  
                     <tr>
                         <td width="100px"><p><font color="black" size="3">(<span id="countcomment"><?php echo $count; ?></span>) Bình luận</font></p></td> 
                         <td width="500px" > 
                             <!-- AddThis Button BEGIN -->
                                <div class="addthis_toolbox addthis_default_style ">
                                <a class="addthis_button_preferred_1"></a>
                                <a class="addthis_button_preferred_2"></a>
                                <a class="addthis_button_preferred_3"></a>
                                <a class="addthis_button_preferred_4"></a>
                                <a class="addthis_button_compact"></a>
                                <a class="addthis_counter addthis_bubble_style"></a>
                                </div>
                                <script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
                                <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-509f1e4359e2c5fe"></script>
                                <!-- AddThis Button END -->
                         </td> 
                    </tr>
                    <tr>
                        <td colspan="2"><input size="100px" id="name" name="name" type="text" value="Họ tên" onFocus="if (this.value=='Họ tên') this.value='';" onBlur="if (this.value=='') this.value='Họ tên';"  /><br></td>
                    </tr>
                    <tr>
                        <td colspan="2"><input size="100px" id="email" name="email" type="text" value="Email" onFocus="if (this.value=='Email') this.value='';" onBlur="if (this.value=='') this.value='Email';"  /><br></td>                   
            
                    </tr>
                    <tr>
                        <td colspan="2"><textarea cols="75" rows="3" id="content"></textarea></td>                   
            
                    </tr>
                     <tr>
                         <td colspan="2"><input type="button" name="binhluan" value="Bình luận" class="button" onclick="comment()">
                             <span id="test"></span>
                         </td>
                    </tr>
                   
                     
                </table>
                <div id="comment">
                <table  width="700px" class="comment">
                     <tr >
                        <td colspan="2"><font color="black" size="3"><p>Lời bình gần đây</p></font></td>
                    </tr>
                     <?php
                            $arr_comment=  getComment($ID_Article);
                            foreach ($arr_comment as $comment) {                 
                         ?>
                     <tr id="showhidecomment">
                         <td colspan="2" class="showcomment">
                             <font color="blue" size="2"><p><?php echo $comment[2].'<font color="black"> -- Ngày bình luận: -- </font>'.$comment[4]; ?></p></font>
                              <font color="black" size="3"><p><?php echo $comment[1]; ?></p></font>
                         </td>                 
                    </tr>
                      <?php
                            }
                            ?>
                </table>
                </div>
                 <div id="comment">
                <table width="700px">
                    
                            <tr>
                                <td width="400px"><font color="#E60000" font-family="Times New Roman" size="4">Các chủ đề khác</font></td>
                                <td width="200px" ><font color="#E60000" font-family="Times New Roman" size="3">Ngày đăng</font></td>
                            </tr>
                             <?php 
                        foreach ($arr_article as $value) {
                                ?>
                              <tr>
                                  <td ><a href="v_ArticleDetail.php?ID_Article=<?php echo $value[0]; ?>"><?php echo $value[1]; ?></a></td> 
                                 <td> <?php echo $value[4]; ?></td> 
                            </tr>
                            <?php }?>
                        </table>  
                 </div>
                    </div>
                    </div>
		</div> 
		
		<?php include('../element/footer.php'); ?>
</div>
</body>
</html>
